//
//  LevelViewController.m
//  penzer
//
//  Created by caiyc on 2018/10/19.
//  Copyright © 2018年 caiyc. All rights reserved.
//

#import "LevelViewController.h"
#import "CProGressView.h"
@interface LevelViewController ()
@property (weak, nonatomic) IBOutlet UIImageView *icon;
@property (weak, nonatomic) IBOutlet UILabel *nick;
@property (weak, nonatomic) IBOutlet UILabel *loevelName;
@property (weak, nonatomic) IBOutlet UILabel *ablityLab;
@property (weak, nonatomic) IBOutlet UILabel *qianggou;
@property (weak, nonatomic) IBOutlet UIView *progressView;
@property (weak, nonatomic) IBOutlet UIScrollView *botom_ScroView;

@end

@implementation LevelViewController

- (void)viewDidLoad {
    [super viewDidLoad];
     [self setNavigation:1 andTitle:@"等级" andNaviColor:[UIColor whiteColor] andTitleColor:nil];
    [self setViews];
    // Do any additional setup after loading the view from its nib.
}
-(void)setViews{
    CGFloat percent = 0.0;
    if([XTool GetDefaultInfo:USER_INFO]){
        NSDictionary *userDic = [XTool GetDefaultInfo:USER_INFO];
        NSLog(@".......%@",userDic);
        NSURL *url = [NSURL URLWithString:userDic[@"avatar"]];
        [self.icon sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"Bitmap"]];
        self.nick.text = [NSString stringWithFormat:@"您好，%@",userDic[@"nickname"]];
        self.level_Lab.text = [NSString stringWithFormat:@"还差%@经验值升级",userDic[@"next_level"]];
        NSInteger level  = [userDic[@"groupid"]integerValue]+1;
        NSString *str = [NSString stringWithFormat:@"level%ld",level];
        self.levle_Img.image = [UIImage imageNamed:str];
        self.leve_Name.text = userDic[@"group_name"]?userDic[@"group_name"]:@"暂无等级";
        NSInteger totals = [userDic[@"exp"]integerValue]+[userDic[@"next_level"]integerValue];
        percent =  [userDic[@"exp"]floatValue]/totals;
    }
    self.icon.layer.cornerRadius = 30;
    self.icon.layer.masksToBounds = 1;
    self.loevelName.layer.cornerRadius = 13;
    self.loevelName.layer.masksToBounds = 1;
    self.ablityLab.layer.cornerRadius = 14;
    self.ablityLab.layer.masksToBounds = 1;
    self.lveViuew.layer.cornerRadius = 14;
    self.lveViuew.layer.masksToBounds = 1;
    self.infoView.layer.cornerRadius = 5;
    self.infoView.layer.masksToBounds = 1;
    CProGressView *progress = [[CProGressView alloc]initWithFrame:CGRectMake(0, 0, self.progressView.frame.size.width-30, 7)];
    [self.progressView addSubview:progress];
   progress.progressValue = [NSString stringWithFormat:@"%.2f",percent];
    self.botom_ScroView.contentSize = CGSizeMake(screen_width, screen_height*1.1);
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
